// This example shows how subscribe to changes of multiple items with percent deadband. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using System.Threading; using OpcLabs.BaseLib.ComInterop; using OpcLabs.EasyOpc; using OpcLabs.EasyOpc.DataAccess; using OpcLabs.EasyOpc.DataAccess.OperationModel; namespace DocExamples.DataAccess.Xml { partial class SubscribeMultipleItems { public static void PercentDeadbandXml() { // Instantiate the client object. using (var client = new EasyDAClient()) { client.ItemChanged += client_PercentDeadband_ItemChanged; Console.WriteLine("Subscribing with different percent deadbands..."); client.SubscribeMultipleItems( new[] { new DAItemGroupArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", new DAItemDescriptor("Dynamic/Analog Types/Int", VarTypes.Empty), new DAGroupParameters(requestedUpdateRate:100, percentDeadband:10.0f), null), new DAItemGroupArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", new DAItemDescriptor("Dynamic/Analog Types/Double", VarTypes.Empty), new DAGroupParameters(requestedUpdateRate:100, percentDeadband:5.0f), null), }); Console.WriteLine("Processing item changed events for 1 minute..."); Thread.Sleep(60 * 1000); } } // Item changed event handler static void client_PercentDeadband_ItemChanged(object sender, EasyDAItemChangedEventArgs e) { if (e.Succeeded) Console.WriteLine("{0}: {1}", e.Arguments.ItemDescriptor.ItemId, e.Vtq); else Console.WriteLine("{0} *** Failure: {1}", e.Arguments.ItemDescriptor.ItemId, e.ErrorMessageBrief); } } }
' This example shows how subscribe to changes of multiple items with percent deadband. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET . ' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own ' a commercial license in order to use Online Forums, and we reply to every post. Imports System.Threading Imports OpcLabs.BaseLib.ComInterop Imports OpcLabs.EasyOpc.DataAccess Imports OpcLabs.EasyOpc.DataAccess.OperationModel Namespace DataAccess.Xml Partial Friend Class SubscribeMultipleItems Public Shared Sub PercentDeadbandXml() ' Instantiate the client object. Using client = New EasyDAClient() AddHandler client.ItemChanged, AddressOf client_PercentDeadband_ItemChanged Console.WriteLine("Subscribing with different percent deadbands...") client.SubscribeMultipleItems(New DAItemGroupArguments() { New DAItemGroupArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", New DAItemDescriptor("Dynamic/Analog Types/Int", VarTypes.Empty), New DAGroupParameters(requestedUpdateRate:=100, percentDeadband:=10.0F), Nothing), New DAItemGroupArguments("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", New DAItemDescriptor("Dynamic/Analog Types/Double", VarTypes.Empty), New DAGroupParameters(requestedUpdateRate:=100, percentDeadband:=5.0F), Nothing) }) Console.WriteLine("Processing item changed events for 1 minute...") Thread.Sleep(60 * 1000) End Using End Sub ' Item changed event handler Private Shared Sub client_PercentDeadband_ItemChanged(ByVal sender As Object, ByVal e As EasyDAItemChangedEventArgs) If e.Succeeded Then Console.WriteLine("{0}: {1}", e.Arguments.ItemDescriptor.ItemId, e.Vtq) Else Console.WriteLine("{0} *** Failure: {1}", e.Arguments.ItemDescriptor.ItemId, e.ErrorMessageBrief) End If End Sub End Class End Namespace
# This example shows how subscribe to changes of multiple items with percent deadband. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc import time # Import .NET namespaces. from OpcLabs.BaseLib.ComInterop import * from OpcLabs.EasyOpc import * from OpcLabs.EasyOpc.DataAccess import * from OpcLabs.EasyOpc.DataAccess.OperationModel import * # Item changed event handler def itemChanged(sender, e): if e.Succeeded: print(e.Arguments.ItemDescriptor.ItemId, ': ', e.Vtq, sep='') else: print(e.Arguments.ItemDescriptor.ItemId, ' *** Failure: ', e.ErrorMessageBrief, sep='') # Instantiate the client object client = EasyDAClient() client.ItemChanged += itemChanged print('Subscribing with different percent deadbands...') IEasyDAClientExtension.SubscribeMultipleItems(client, [ DAItemGroupArguments( ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'), DAItemDescriptor('Dynamic/Analog Types/Int', VarType(VarTypes.Empty)), DAGroupParameters(100, 10.0), None), DAItemGroupArguments( ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'), DAItemDescriptor('Dynamic/Analog Types/Double', VarType(VarTypes.Empty)), DAGroupParameters(100, 5.0), None), ]) print('Processing item change notifications for 1 minute...') time.sleep(60) print('Unsubscribing all items...') client.UnsubscribeAllItems() client.ItemChanged -= itemChanged print('Finished.')
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved.
Documentation Home, Send Documentation Feedback. Technical Support